package com.ling.pl.security.view.frame.main;

import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.Expose;
import com.bstek.dorado.web.DoradoContext;
import com.bstek.dorado.web.WebConfigure;
import com.ling.pl.security.feign.DefaultUrlService;
import com.ling.pl.security.model.DefaultUrlVO;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import java.util.Collection;

/**
 * @author bo.wang
 * @since 2013-2-1
 */
@Controller("ling2.mainFrame")
public class MainFrame {
    public static final String BEAN_ID = "ling2.mainFrame";
    @Resource
    DefaultUrlService urlService;

    @DataProvider
    @SuppressWarnings("unchecked")
    public Collection<DefaultUrlVO> loadMeunUrls(String parentId) {
        Collection<DefaultUrlVO> results = urlService.loadMeunUrlsFromCache(parentId);
        return results;
    }

    @DataProvider
    public Collection<DefaultUrlVO> loadContainChildMeunUrls(String parentId) {
        return urlService.loadContainChildMeunUrlsFromCache(parentId);
    }

    @Expose
    public void changeSkin(String skin) {
        WebConfigure.set(DoradoContext.SESSION, "view.skin", skin);
    }
}
